
import java.util.ArrayList;
import java.util.List;

/**
 * Created by cc
 * Description:
 * User: CZH
 * Date: 2022-09-28
 * Time: 13:19
 */
public class Test01 {

    public static void main(String[] args) {
        String str = "abcqweracb";
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (sb.toString().contains(str.charAt(i) + "")) {
                sb.append(str.charAt(i));
            }
        }
        System.out.println(sb);

    }

    public static void main1(String[] args) {
        String str = "abcqweracb";
        List<Character> list = new ArrayList<>();
        for (int i = 0; i < str.length(); i++) {
            boolean isFlag = true;
            for (int j = 0; j < list.size(); j++) {
                if (str.charAt(i) == list.get(j)) {
                    isFlag = false;
                    break;
                }
            }
            if (isFlag == true) {
                list.add(str.charAt(i));
            }
        }
        String str2 = list.toString();
        System.out.println(str2);
    }
}
